<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <!--[if lt IE 9]>
    <script src="/js/html5.min.js"></script>
    <script src="/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>
	<style>
		.layui-table img {
    max-width: 50px!important;
}
	</style>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">

                <div class="layui-card-body layui-table-body layui-table-main">

                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend>订单信息</legend>
                    </fieldset>

                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>订单编号</th>
                            <th>支付价格</th>
                            <th>订单状态</th>
                            <th>付款时间</th>
                            <th>下单时间</th>
                            <?php if ($order['order_status']==10): ?><th>修改价格</th> <?php endif; ?>
                           
                        </tr>
                        </thead>
                        <tbody>
                    
                        <tr>
                            <td><?= $order['order_no'] ?></td>
                            <td><?= $order['pay_price'] ?></td>
                            <td><?php 
                            switch ($order['order_status']) {
                            	case 10:
                            	echo '待付款'; 
                            	break;
                            	
                            	case 20:
                            	echo '待发货'; 
                            	break;
                            	
                            	case 30:
                            	echo '待收货'; 
                            	break;
                            	
                            	case 40:
                            	echo '已完成'; 
                            	break;
                            	case 50:
                            	echo '已取消'; 
                            	break;
                            }
                             ?></td>
                         
                         <td><?= date('Y-m-d H:i:s',$order['pay_time']) ?></td>
                         <td><?= date('Y-m-d H:i:s',$order['create_time']) ?></td>
                         <?php if ($order['order_status']==10): ?><td><button onclick="xadmin.open('修改价格','/order/price/<?= $order['order_id'] ?>',500,400)" type="button"  class="layui-btn">修改价格</button></td><?php endif; ?>
                        </tr>
               
                        </tbody>
                    </table>


                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend>商品信息</legend>
                    </fieldset>
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>商品ID</th>
                            <th>商品名称</th>
                            <th>商品图片</th>
                            <th>购买数量</th>
                            <th>商品价格</th>
                            <th>商品总价</th>
                        </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($goods as $v): ?>
                            <tr>
                                <td><?= $v['goods_id'] ?></td>
                                <td><?= $v['goods_name'] ?></td>
                                <td><img src="<?= $v['image'] ?>"></td>
                                <td><?= $v['goods_num'] ?></td>
                                <td><?= $v['goods_price'] ?></td>
                                <td><?= $v['goods_num']*$v['goods_price'] ?></td>
                                 </tr>
                            <?php endforeach; ?>
                       
                        </tbody>
                    </table>

                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend>收货地址</legend>
                    </fieldset>
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>收件人</th>
                            <th>联系电话</th>
                            <th>省份</th>
                            <th>城市</th>
                            <th>地区</th>
                            <th>详细地址</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                                <td><?= $address['name'] ?></td>
                                <td><?= $address['phone'] ?></td>
                                <td><?= $address['province'] ?></td>
                                <td><?= $address['city'] ?></td>
                                <td><?= $address['region'] ?></td>
                                <td><?= $address['detail'] ?></td>
                        </tr>
        
                        </tbody>
                    </table>


                <?php if ($order['invoice']>0): ?>
                      <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend>发票信息</legend>
                    </fieldset>
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                        	<th>抬头</th>
                            <th>邮箱</th>
                            <th>税号</th>
                            <th>单位地址</th>
                            <th>电话号码</th>
                            <th>开户银行</th>
                            <th>银行账号</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                                <td><?= $invoice['name'] ?></td>
                                <td><?= $invoice['email'] ?></td>
                                <td><?= $invoice['tax'] ?></td>
                                <td><?= $invoice['address'] ?></td>
                                <td><?= $invoice['phone'] ?></td>
                                <td><?= $invoice['bank_name'] ?></td>
                                <td><?= $invoice['bank_code'] ?></td>
                        </tr>
        
                        </tbody>
                    </table>
                <?php endif; ?>
                      
          
             <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
              <legend>物流信息</legend>
              </fieldset>                  
<?php if ($order['order_status']==20): ?>

    		<form class="layui-form" id="form">
    			
			<div class="layui-form-item">
				<label class="layui-form-label"><span class="x-red">*</span>快递公司</label>
				<div class="layui-input-inline">
					
					    <select name="express_id" >
                        <?php foreach ($express as $v): ?>
                            <option value="<?= $v['express_id'] ?>"><?= $v['express_name'] ?></option>
                        <?php endforeach; ?>
                    </select>
                 <input type="hidden" value="<?= $order['order_id'] ?>"  name="order_id" ></div>
				</div>
		


			<div class="layui-form-item">
				<label for="phone" class="layui-form-label"><span class="x-red">*</span>快递单号</label>
				<div class="layui-input-inline">
					<input type="text" value=""  name="number" lay-verify="required" autocomplete="off" class="layui-input"></div>
			</div>





			<div class="layui-form-item">
				<label for="L_repass" class="layui-form-label"></label>
				<button type="button" id="btn" class="layui-btn" lay-submit="" lay-filter="add">保存</button>
			</div>
		</form>
    
<?php else: ?>
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>快递公司</th>
                            <th>快递单号</th>
                             <th>发货时间</th>
                        </tr>
                        </thead>
                         <tbody>
                            <tr>
                               <td><?= $order['express'] ?></td>
                               <td><?= $order['number'] ?></td>
                               <td><?= date('Y-m-d H:i:s',$order['deliver_time']) ?></td>
                            </tr>

                        </tbody>
                    </table>
<?php endif; ?></div>
                <div class="layui-card-body">
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['form'], function(){});
    
        $('#btn').click(function () {
        $.ajax({
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url:'/order/deliver',
            data:new FormData(document.getElementById("form")),
            processData:false,
            contentType:false,
            success: function (res) {
                if (res.code){
                    layer.msg(res.msg);
                    setTimeout(function () {
                        parent.location.reload();
                    },500);

                }else{
                    layer.msg(res.msg);
                }
            },
            error : function() {

            }
        });
    });
    
    </script>
</html>